package com.yuexun.dhdoctor.module.personalPlan.presenter.impl;


import com.yuexun.dhdoctor.base.BaseEntity;
import com.yuexun.dhdoctor.module.personalPlan.model.IPlanModel;
import com.yuexun.dhdoctor.module.personalPlan.presenter.IScheduleDeletePresenter;
import com.yuexun.dhdoctor.module.personalPlan.ui.view.IScheduleDeleteView;

import java.util.Map;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by Administrator on 2017/4/21 0021.
 */

public class ScheduleDeletePresenter implements IScheduleDeletePresenter {

    private IScheduleDeleteView view;
    private IPlanModel model;

    public ScheduleDeletePresenter(IPlanModel model, IScheduleDeleteView view) {
        this.model = model;
        this.view = view;
    }

    @Override
    public void deleteSchedule(Map<String, String> praise) {
        model.deleteSchedule(praise)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<BaseEntity>() {

                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                    }

                    @Override
                    public void onNext(BaseEntity s) {
                        view.deleteSchedule(s);
                    }
                });
    }
}
